<?php 
	class RegisterController extends CommonController{
		public function index(){
			if(IS_POST){

			$username = Q('post.account');
			$password = Q('post.password');

			if(strtoupper($_POST['regcode'])!=$_SESSION['code']) $this->error( "验证码错误");
			$userInfo = $this->model->get_one_data(array('username'=>$username));
			if($userInfo) $this->error('用户名已经存在');
			// 匹配密码
			$preg = '/^[a-zA-Z][a-zA-Z0-9]{5,}$/';
			$pwdInfo = preg_match($preg, $password);

			if(!$pwdInfo) $this->error('密码必须以字母开头，不小于六位');

			$data = array(
				'username' => $username,
				'passwd' => md5($password),
				
				);
			
			$this->model->add_data($data);

			$this->success('注册成功',U('Shoplist/index'));	





			}

			$this->display();
		}


		PUBLIC function regcode(){
				if(IS_AJAX){
				if(strtoupper($_POST['regcode'])==$_SESSION['code']){// 验证通过
				echo 1;
				}else{// 验证失败
				 echo 0;
				}
				exit;
			}
		}



	}



 ?>